<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/6 23:58
 */

namespace module\ai\library\channel\platform;

use module\ai\library\channel\abstract\Platform;
use mof\Model;

class DoubaoPlatform extends Platform
{
    protected string $regUrl = 'https://console.volcengine.com/auth/login';

    public static function getName(): string
    {
        return '豆包AI';
    }

    public static function getFlag(): string
    {
        return 'doubao';
    }

    public function getConfigForm(Model $model = null): array
    {
        return [
            [
                "label" => "接入点ID",
                "prop"  => "config.model",
                "value" => $model['config']['model'] ?? "",
                "type"  => "input",
                "intro" => "请输入推理接入点名称(ep-开头)。请在【火山引擎-在线推理】里创建推理接入点。",
            ],
            [
                "label" => "temperature",
                "prop"  => "config.temperature",
                "value" => $model['config']['temperature'] ?? '',
                "intro" => "采样温度。控制了生成文本时对每个候选词的概率分布进行平滑的程度。取值范围为 [0, 1]。",
                "tip"   => "较高的值（如 0.8）会使输出更加随机，而较低的值（如 0.2）会使输出更加集中确定。<br>" .
                    "通常建议仅调整 temperature 或 top_p 其中之一，不建议两者都修改。"
            ],
            [
                "label" => "top_p",
                "prop"  => "config.top_p",
                "value" => $model['config']['top_p'] ?? '',
                "intro" => "核采样概率阈值。模型会考虑概率质量在 top_p 内的 token 结果。取值范围为 [0, 1]。",
                "tip"   => "取值越大生成的随机性越高，取值越低生成的确定性越高。<br>" .
                    "通常建议仅调整 temperature 或 top_p 其中之一，不建议两者都修改。"
            ],
            [
                "label" => "presence_penalty",
                "prop"  => "config.presence_penalty",
                "value" => $model['config']['presence_penalty'] ?? '',
                "intro" => "存在惩罚系数。取值范围为 [-2.0, 2.0]",
                "tip"   => "如果值为正，会根据新 token 到目前为止是否出现在文本中对其进行惩罚，从而增加模型谈论新主题的可能性。"
            ],
            [
                "label" => "frequency_penalty",
                "prop"  => "config.frequency_penalty",
                "value" => $model['config']['frequency_penalty'] ?? '',
                "intro" => "频率惩罚系数。取值范围为 [-2.0, 2.0]",
                "tip"   => "如果值为正，会根据新 token 在文本中的出现频率对其进行惩罚，从而降低模型逐字重复的可能性。"
            ],
        ];
    }

    public function getKeyColumns(): array
    {
        return [
            'api_key' => [
                'label'  => 'API Key',
                'secret' => true,
            ]
        ];
    }

}